package com.bsj.media.media.self;
import com.bsj.consumerQ.until.ExceptionUntil;
import com.bsj.media.media.FlvAudioStream;
import com.bsj.media.media.VideoServerCmdType;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MySelfFlvAudio extends FlvAudioStream {

    public MySelfFlvAudio() {
        super(VideoServerCmdType.AUDIO);
    }

    public int packetData(byte[] fdBody, byte[] dstBuffer) {
        if (fdBody != null) {
            int packetLen = 0;
            try {
                // 提取FDFD协议数据的数据体，19字节+body+校验1+结束位1
                byte[] body = fdBody;
                if (!isPacketFlvHeader) {
                    // 打FLV头，h264信息
                    packetLen = PacketFirstFLV(body, dstBuffer);
                } else {
                    packetLen = PacketSecondFLV(body, dstBuffer, 0);
                }
            } catch (Exception e) {
                log.error("打包数据异常！" + ExceptionUntil.getErrorStr(e));
            }
            return packetLen;
        }
        return 0;
    }
}
